package com.jml.反射;

import java.lang.reflect.Method;

public class 反射执行方法 {

    public static void main(String[] args) throws Exception {
        Class<?> forName = Class.forName("com.jml.反射.反射执行方法");
        Object instance = forName.newInstance();
        Method declaredMethod = forName.getDeclaredMethod("sum", int.class, int.class);
        declaredMethod.invoke(instance,1,2);
    }
    private static void sum(int a, int b) {
        System.out.println("执行了a:"+a+"  b:"+b);
    }
}
